CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)

FIND_PACKAGE(OpenCV REQUIRED core imgproc)
INCLUDE_DIRECTORIES(AFTER ${OpenCV_INCLUDE_DIR})
ADD_DEFINITIONS(-DTRAX_BUILD_OPENCV)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
ADD_LIBRARY(trax_opencv SHARED opencv.cpp)
TARGET_LINK_LIBRARIES(trax_opencv trax ${OpenCV_LIBS})
INSTALL(FILES "include/trax/opencv.hpp" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/trax)

SET_TARGET_PROPERTIES(trax_opencv PROPERTIES VERSION ${BUILD_VERSION} SOVERSION 1)

IF (WIN32 OR WIN64)
	INSTALL(TARGETS trax_opencv EXPORT opencv
		RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
		LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
		ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
ELSE ()
	INSTALL(TARGETS trax_opencv EXPORT opencv
		RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
		LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
		ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
ENDIF()

#ADD_EXECUTABLE(camshift camshift.cpp)
ADD_EXECUTABLE(interactive interactive.cpp)
#TARGET_LINK_LIBRARIES(camshift trax trax_opencv ${OpenCV_LIBS})
TARGET_LINK_LIBRARIES(interactive trax trax_opencv ${OpenCV_LIBS})

INSTALL(EXPORT opencv DESTINATION ${CONFIG_INSTALL_DIR} FILE trax-component-opencv.cmake)

